package com.qili.service;


import com.qili.base.service.BaseService;
import com.qili.entity.sys.SysRoleUser;
import com.qili.entity.sys.SysUser;
import com.qili.entity.sys.dto.SysRoleUserDTO;
import com.qili.entity.sys.dto.SysUserDTO;
import com.qili.util.Checkbox;
import com.qili.util.JsonUtil;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author zhuxiaomeng
 * @date 2017/12/4.
 * @email 154040976@qq.com
 */
public interface SysUserService extends BaseService<SysUser, String> {

    /**
     * @param username
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    SysUser login(String username);

    /**
     * @Author:Zhangshuo
     * @Description:
     * @param id
     * @Date:10:24 2020/11/23
     */
    SysUser selectByPrimaryKey(String id);

    /**
     * @Author:Zhangshuo
     * @Description:
     * @param id
     * @Date:10:24 2020/11/23
     */
    SysUserDTO selectUserById(String id);

    /**
     * 分页查询
     *
     * @param
     * @return
     */
    @Override
    List<SysUser> selectListByPage(SysUser sysUser);

    int count();

    /**
     * 新增
     *
     * @param user
     * @return
     */
    int add(SysUser user);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    JsonUtil delById(String id, boolean flag);

    /**
     * @param username
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:22 2020/11/23
     */
    int checkUser(String username);

    /**
     * @param sysUser
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:22 2020/11/23
     */
    @Override
    int updateByPrimaryKey(SysUser sysUser);

    /**
     * @param sysRoleUser
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:22 2020/11/23
     */
    List<SysRoleUser> selectByCondition(SysRoleUser sysRoleUser);

    /**
     * @param id
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:22 2020/11/23
     */
    public List<Checkbox> getUserRoleByJson(String id);

    /**
     * 更新密码
     *
     * @param user
     * @return
     */
    int rePass(SysUser user);

    /**
     * @param roleId
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    List<SysUser> getUserByRoleId(String roleId);

    /**
     * @param username
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    public void setMenuAndRoles(String username);

    /* *
     * @Author liuyang
     * roleSeted
     */
    public void setMenuAndRolesWhenRegist(SysUser user,List<String>  rolelist);

    /**
     * @param user
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    public void updateCurrent(SysUser user);

    /**
     * @param email
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    SysUser selectByEmail(String email);

    /**
     * @param id
     * @param passwordNew
     * @param name
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    int updateById(String id, String passwordNew, String name);

    /**
     * @param id
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    SysUser selectById(String id);

    /**
     * @param sysUser
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    int updateUser(SysUser sysUser);

    /**
     * @param sysUser
     * @Author:Zhangshuo
     * @Description:
     * @Date:10:23 2020/11/23
     */
    int updateNum(SysUser sysUser);

    /**
     * @Author:Zhangshuo
     * @Description: 根据单位或者其他条件（可加）获取用户字典数据
     * @param sysUser
     * @Date:13:57 2020/11/23
     */
    List<SysUser> getUserDicts(SysUserDTO sysUser);

    /* *
     * @Author liuyang
     * @Date 18:22 2020/12/7
     * @Description     设置用户的业务类型名称
     * @Param           需要设置的用户对象
     * @return void
     */
    void selectUserYwTypeName(SysUserDTO user);
    /**
    * @Author:zhaoyongke
    * @Description: 判断该用户是否存在 某个角色
    * @param userId
    * @param roleName
    * @Date:17:47 2020/12/10
    */
    public List<SysRoleUser> querySysRoleByRoleName(String userId, String roleName);

    /**
    * @Author:Zhangshuo
    * @Description: 更新tags
    * @param sysUser
    * @Date:13:31 2020-12-14
    */
    void updateTags(SysUser sysUser);

    /**
     * 判断手机号码是否重复
     * @param sysUser       需要判断的对象,包含手机号
     * @return              有重复的 flag为false  没有重复的,或者参数的手机号码为null,flag为true
     */
    JsonUtil checkSameTelephone(SysUser sysUser);

    /**
     * 用户更改时判断手机号重复,查找id不为我自己的相同的手机号码
     * @param sysUser
     * @return
     */
    JsonUtil checkSameTelephoneWhenUpdate(SysUser sysUser);

    /**
     * 用户更改是判断邮箱重复,查找id不为我自己的相同的email
     * @param sysUser
     * @return
     */
    JsonUtil checkSameEmailWhenUpdate(SysUser sysUser);

    /**
     * 验证密码是否符合需求
     * @param pwd
     * @return
     */
    boolean checkUserPassword(String pwd);

    /**
     * 获取建设单位管理人数
     * @return
     */
    String getJsdwglrCount();

    /**
     * 验证数据库中是否有重名的，
     * @param newUserName       如果有重名的后面添加数字返回，如果没有重名的返回原参数
     * @return
     */
    String checkAndHandlerSameNewUserName(String newUserName);

    /**
     * 获取新的建设单位管理员用户名
     * admin  +  省名称的拼音缩写  +  0001  ->   往下排   例如   adminsd   adminsd0001
     * @param provinceName
     * @return
     */
    String getNewUserName(String provinceName);

    /**
     * 查询项目的管理员账号
     * @param projectId
     * @return
     */
    List<SysUserDTO> selectProjectAdmin(String projectId);

    /**
     * 获取可用的用户列表(del_flat为0的)
     * @return
     */
    List<SysUserDTO> selectUsefulUsers(SysUser user);


    /**
     * 创建用户文档路径
     * @param user
     */
    void setUserFilePath(SysUser user);

    void updateUserNowWork(SysUser sysUser);

    /**
     * 更改用户状态
     */
    void updateUserAuditStatus(String userId,String auditStatus,String reason);
    /**
     * @Author:zhaoyongke
     * @Description:判断用户是否含有某个角色
     * @param permission
     * @Date:11:38 2021/2/20
     */
    public Boolean isHasPermission(String permission);

    /**
     * 批量导入用户信息
     * @param file
     * @param message
     * @return
     */
    StringBuffer buldImportSqtj(MultipartFile file, StringBuffer message);

    /**
     * 批量导入用户角色信息
     * @param file
     * @param message
     * @return
     */
    StringBuffer importUserRoles(MultipartFile file, StringBuffer message);

    /**
     * 验证用户导入的公司名称是否包含
     * @param orgName
     * @return
     */
    boolean checkUserOrg(String orgName);
    /**
    * @Author:zhaoyongke
    * @Description:
    * @param projectId
    * @Date:11:20 2021/2/25
    */
    public String getUserRole(String projectId);

    public String getUserRoleJlApp(String projectId,String userId);

    /**
     * @Author:zhaoyongke
     * @Description:
     * @param projectId
     * @Date:11:20 2021/2/25
     */
    public String getUserRoleZx(String projectId);

    public String getUserRoleJc(String projectId);

    /**
     * @Author:zhaoyongke
     * @Description:咨询获取用户角色
     * @param projectId
     * @Date:11:20 2021/2/25
     */
    public String getZxUserRole(String projectId);

    /**
     * 根据邮箱号获取数据库中用户个数
     * @param email
     * @return
     */
    int checkUserEmail(String email);

    String getJcUserRole(String projectId);

    List<String> selectUserIdListForPushMsg(String applicantId);

    /**
     * 根据手机号查询用户信息
     * @param phoneNumber
     * @return
     */
    SysUser phoneLogin(String phoneNumber);


    int updateUserPassWordByPhone(String phoneNumber, String password);

    int updatePasswordUsername(String username, String password);

    SysUser selectUser(String username);

    List<SysRoleUserDTO> selectRoleUserByUser(SysRoleUserDTO dto);

    /**
     * 导出用户角色
     * @param dto
     * @return
     */
    List<SysUserDTO> selectExportUsers(SysUserDTO dto);
}
